<include file="public:header" />
<form action="{:u('items/batch_add')}" method="post" name="myform" id="myform"  enctype="multipart/form-data" style="margin-top:10px;">
    <div class="pad-10">
        <div class="col-tab">
            <ul class="tabBut cu-li">
                <li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',2,1);">基本信息</li>
            </ul>
            <div id="div_setting_1" class="contentList pad-10">
            <div class="explain-col">
					&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>注：一行一个“淘宝，天猫”的URL</font><br/>
                    &nbsp;&nbsp;&nbsp;&nbsp;http://detail.tmall.com/item.htm?id=12903959631<br/>
					&nbsp;&nbsp;&nbsp;&nbsp;http://detail.tmall.com/item.htm?id=12903959631<br/>
					&nbsp;&nbsp;&nbsp;&nbsp;…………<br/>
					&nbsp;&nbsp;&nbsp;&nbsp;http://detail.tmall.com/item.htm?id=12903959631<br/>
					
				</div>
                <table>
                    <tr>
                        <th width="120">商品归类 :</th>
                        <td><select name="cid" id="cid" onchange="return check_cate(this);">
                                <option value="0">--请选择分类--</option>
                                <volist name="cate_list['parent']" id="val"> 
                                	<option pid="0" value="{$val.id}"<if condition="$items['cid'] eq $val['id']"> selected="selected" </if>>
                                    {:trim($val['name'])}
                                    </option>
                                    <notempty name="cate_list['sub'][$val['id']]">
                                        <volist name="cate_list['sub'][$val['id']]" id="sval"> <option value="{$sval.id}"<if condition="$items['cid'] eq $sval['id']"> selected="selected" </if>>&nbsp;&nbsp;&nbsp;&nbsp;{:trim($sval['name'])}
                                            </option>
                                        </volist>
                                    </notempty>
                                </volist>
                            </select></td>
                    </tr>
                    <tr>
                    	<th>网址URL：</th>
                        <td>
                			<textarea name="urls" id="urls" cols="100" rows="10"></textarea>        
                        </td>
                    </tr>   
                    <tr>
                    	<th>抓取消息:</th>
                        <td id="cmd">
                        </td>
                    </tr>                 
                </table>
            </div>
            <div class="btn">
                <input type="button" value="抓取" class="button" onclick="collect();">
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
function collect(){ 
	$('#cmd').show();
	
	if($('#cid').val()=='0'){ 
		console.log($('#cid').val());	
		alert('请选择分类');
		return;
	}	
	$.post("{:u('items/batch_add')}",{dosubmit:true,urls:$('#urls').val(),cid:$('#cid').val()},function(data){
		$('#cmd').html("");																								
		var html="<div><h4>成功更新列表:</h4><div style='color:blue;'>"+data.data.success_update_list+"</div></div><br/>\
		<div><h4>成功添加列表:</h4><div style='color:green;'>"+data.data.success_insert_list+"</div></div>\
		<div><h4>失败列表:</h4><div style='color:red;'>"+data.data.fail_list+"</div></div>";
		$('#cmd').append(html);					  			
		//console.log(data);
	},'json');	
}	
</script>
</body></html>